﻿// See https://aka.ms/new-console-template for more information

using Toolkit;
// 保存原来的颜色设置，以便之后恢复
ConsoleColor originalForeground = Console.ForegroundColor;

Console.WriteLine("####### 欢迎使用 驰骋工作流引擎API演示程序 ");
Console.WriteLine("1. 该演示系统显示通过API访问流程引擎的服务");
Console.WriteLine("2. 服务地址:[" + Config.BPMHost + "]");
Console.WriteLine("3. 项目编号:[" + Config.Domain + "],获取发起、待办、在途数据通过项目编号过滤,编号设置在流程树的属性上,为空标识全局数据.");
Console.WriteLine("4. 按照流程086开始模拟执行登录、创建workID、保存草稿、保存系统参数、保存草稿、执行发送、结束流程等操作。");
Console.WriteLine("##########################################################");

string msg = "";
Console.WriteLine("1.登陆:获得用户token.Port_Login");
ReturnObj obj = Dev2InterfaceRestfulAPI.Port_Login("admin", "123");
TestCase.PrintInfo(obj, originalForeground);


Console.WriteLine("2.获得workID.Node_CreateBlankWorkID");
//生成一个流程实例：WorkID，它是一个长整型的数据。 如果liping不能执行发起此流程系统就抛出错误。
Int64 workID = Dev2InterfaceRestfulAPI.Node_CreateBlankWorkID("082");
TestCase.PrintInfo(obj, originalForeground);


Console.WriteLine("3.保存草稿.Node_SetDraft");
obj = Dev2InterfaceRestfulAPI.Node_SetDraft(workID);
TestCase.PrintInfo(obj, originalForeground);


Console.WriteLine("4.设置参数(全局变量)用于第2个节点【部门经理审核】的方向转向，方向条件设置的系统参数.");
obj = Dev2InterfaceRestfulAPI.Flow_SaveParas(workID, "@JE=3000");
TestCase.PrintInfo(obj, originalForeground);


Console.WriteLine("5.发送到下一个节点[部门经理审批],这里发送liyan.");
obj = Dev2InterfaceRestfulAPI.Node_SendWork(workID, "0","liyan","","审议意见同意");
TestCase.PrintInfo(obj, originalForeground);


Console.WriteLine("6.使用liyan登录,执行发送到下一个节点");
obj = Dev2InterfaceRestfulAPI.Port_Login("liyan", "123");
TestCase.PrintInfo(obj, originalForeground);



Console.WriteLine("7. 部门经理liyan向下发送,根据JE参数判断方向条件,应该发送给总经理审核.");
obj = Dev2InterfaceRestfulAPI.Node_SendWork(workID,"0","","","同意！！！");
TestCase.PrintInfo(obj, originalForeground);


Console.WriteLine("8. 用总经理yuwen登录");
obj = Dev2InterfaceRestfulAPI.Port_Login("yuwen", "123");
TestCase.PrintInfo(obj, originalForeground);


Console.WriteLine("9. 让yuwen执行结束.");
obj = Dev2InterfaceRestfulAPI.Flow_DoFlowOver(workID.ToString());
TestCase.PrintInfo(obj, originalForeground);

// 恢复原来的颜色设置
Console.ForegroundColor = originalForeground;

 











